package net.muchine.core.support;

import java.util.ArrayList;
import java.util.List;

import net.muchine.core.domain.user.Group;
import net.muchine.core.domain.user.GroupUser;
import net.muchine.core.domain.user.Preference;
import net.muchine.core.domain.user.Preference.DisplayComments;
import net.muchine.core.domain.user.Preference.EmailNotification;
import net.muchine.core.domain.user.User;

public class FixtureFactory {
	public List<Group> generateGroups() {
		Group group1 = new Group();
		group1.setCompanyId("lguplus");
		group1.setId("dev");
		group1.setName("Development");
		group1.setDescription("Software Development Dept.");
		group1.setParentId(null);
		group1.setManagerId("sejoon");		
		
		Group group2 = new Group();
		group2.setCompanyId("lguplus");
		group2.setId("op");
		group2.setName("Operation");
		group2.setDescription("Software Operation Dept.");
		group2.setParentId(null);
		group2.setManagerId("sejoon2");
		
		List<Group> groups = new ArrayList<Group>();
		groups.add(group1);
		groups.add(group2);
		
		return groups;
	}
	
	public Group generateUpdateGroup(Group source) {
		Group group = new Group();
		group.setCompanyId(source.getCompanyId());
		group.setSeq(source.getSeq());
		group.setId(source.getId());
		group.setName("Support");
		group.setDescription("SupportDept.");
		group.setParentId(null);
		group.setManagerId("sehyun");
		group.setUsers(10);
		
		return group;
	}
	
	public List<User> generateUsers() {
		User user1 = new User();
		user1.setId("sejoon");
		user1.setFirstName("Sejoon");
		user1.setLastName("Lim");
		user1.setPassword("welcome1");
		user1.setEmail("muchine98@gmail.com");
		user1.setRank("manager");
		user1.setLanguage("en");
		user1.setGroupId("dev");
		user1.setAdmin(true);
		
		User user2 = new User();
		user2.setId("sejoon2");
		user2.setFirstName("Sejoon2");
		user2.setLastName("Lim2");
		user2.setPassword("welcome12");
		user2.setEmail("sejoon@daum.net");
		user2.setRank("ceo");
		user2.setLanguage("ko");
		user2.setGroupId("dev");
		user2.setAdmin(false);
		
		List<User> users = new ArrayList<User>();
		users.add(user1);
		users.add(user2);
		
		return users;
	}
	
	public User generateUpdateUser(User source) {
		User user = new User();
		user.setSeq(source.getSeq());
		user.setId(source.getId());
		user.setFirstName("Sejoon2");
		user.setLastName("Lim2");
		user.setPassword("welcome12");
		user.setEmail("sejoon@daum.net");
		user.setRank("ceo");
		user.setLanguage("ko");
		user.setGroupId("dev");
		user.setAdmin(false);
		
		return user;
	}
	
	public List<Preference> generatePreferences(List<User> users) {
		if (users == null || users.size() < 2) throw new IllegalArgumentException("user list is invalid.");
		
		Preference pref1 = new Preference();
		pref1.setUserSeq(users.get(0).getSeq());
		pref1.setHideEmail(true);
		pref1.setTimeZone("Seoul");
		pref1.setDisplayComments(DisplayComments.CHRONOLOGICAL);
		pref1.setWarnUnsavedText(true);
		pref1.setEmailNotification(EmailNotification.INVOLVED);
		pref1.setNotifyMyChanges(true);
		
		Preference pref2 = new Preference();
		pref2.setUserSeq(users.get(1).getSeq());
		pref2.setHideEmail(false);
		pref2.setTimeZone("London");
		pref2.setDisplayComments(DisplayComments.REVERSE);
		pref2.setWarnUnsavedText(false);
		pref2.setEmailNotification(EmailNotification.ASSIGNED);
		pref2.setNotifyMyChanges(false);
		
		List<Preference> prefs = new ArrayList<Preference>();
		prefs.add(pref1);
		prefs.add(pref2);
		
		return prefs;
	}
	
	public Preference generateUpdatePreference(Preference source) {
		Preference pref = new Preference();
		pref.setSeq(source.getSeq());
		pref.setUserSeq(source.getUserSeq());
		pref.setHideEmail(false);
		pref.setTimeZone("Arizona");
		pref.setDisplayComments(DisplayComments.REVERSE);
		pref.setWarnUnsavedText(false);
		pref.setEmailNotification(EmailNotification.OWN);
		pref.setNotifyMyChanges(false);
		
		return pref;
	}
}
